<%@page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@include file="/wx/page/session.jsp"%>
<c:set var="userId" value="${param.userId}" />
<c:set var="deptId" value="${param.deptId}" />
<c:set var="deptCode" value="${param.deptCode}" />
<c:set var="deptParentId" value="${param.deptParentId}" />
<c:set var="staffType" value="${param.staffType}" />
<c:set var="taskId" value="${param.taskId}" />
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no, width=device-width">
    <meta content="yes" name="apple-mobile-web-app-capable">
    <meta content="black" name="apple-mobile-web-app-status-bar-style">
    <title>收支管理</title>
    <link rel="stylesheet" href="${ctx}/wx/css/default.css"/>
    <script type="text/javascript" src="${ctx}/wx/js/xtable.js"></script>
    <script type="text/javascript" src="${ctx}/dwr/engine.js"></script>
    <script type="text/javascript" src="${ctx}/dwr/util.js"></script>
    <script type="text/javascript" src="${ctx}/dwr/interface/MoneyService.js"></script>
    <script type="text/javascript" src="${ctx}/wx/js/alert.js"></script>
</head>
<body>
<c:if test="${staffType == 1}">
<p class="contact-submit">
    <input type="button" value="新增收支" onclick="insertMoney()">
</p>
</c:if>
<SCRIPT LANGUAGE="JavaScript" type="">
    var moneyThead = new Array(
            new XThead("类型"),
            new XThead("金额"),
            new XThead("备注"),
            new XThead("时间")
    );

    var moneyXTable = new XTable("money", moneyThead, false);

    moneyXTable.XTbodyArray = function (model) {
        var array = new Array(
                new XTbody("money", model.moneyType == 1 ? "信息费" : model.moneyType == 2 ? "销售款" : model.moneyType == 3 ? "采购款" : "", null, null, null, "center"),
                new XTbody("money", "<span style='color:" + (model.moneyInOut == -1 ? "green" : "red") + "'>" + model.moneyAmount * model.moneyInOut + "</span>", null, null, null, "center"),
                new XTbody("money", model.moneyRemark, null, null, null, "center"),
                new XTbody("money", new Date(model.moneyCreateTime).Format("MM/dd hh:mm"), null, null, null, "center")
        );

        return array;
    }

    moneyXTable.getXList = function (page){
        var money = new Money();
        money.deptId = "${deptId}";
        money.taskId = "${taskId}";
        <c:if test="${staffType == 0}">
        money.moneyType = 1;
        </c:if>
        money.pageIndex = page;
        money.pageSize = moneyXTable.pageSize;
        MoneyService.selectMoneyList(money, function(list){moneyXTable.addTable(list);});
    }

    function getMoneyPage(){
        var money = new Money();
        money.deptId = "${deptId}";
        money.taskId = "${taskId}";
        <c:if test="${staffType == 0}">
        money.moneyType = 1;
        </c:if>
        MoneyService.selectMoneyNum(money, function(num){moneyXTable.setTotalPage(num);});
    }
</SCRIPT>
</body>
</html>
<script type="text/javascript">
    parent.document.title = "收支管理";
    getMoneyPage();
    function insertMoney() {
        location = "${ctx}/wx/page/money_manage.jsp?userId=${userId}&deptId=${deptId}&deptCode=${deptCode}&deptParentId=${deptParentId}&taskId=${taskId}";
    }
</script>